<template>
  <div>
    <el-breadcrumb separator-icon="ArrowRight" style="margin: 16px">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
      <el-breadcrumb-item>宿管信息</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card style="margin: 15px; min-height: calc(100vh - 111px)">
      <div>
        <!--    功能区-->
        <div style="margin: 10px 0">
          <!--    搜索区-->
          <div style="margin: 10px 0">
            <el-input
              v-model="search"
              clearable
              placeholder="请输入姓名"
              prefix-icon="Search"
              style="width: 20%"
            />
            <el-button
              icon="Search"
              style="margin-left: 5px"
              type="primary"
              @click="load"
            ></el-button>
            <el-button
              icon="refresh-left"
              style="margin-left: 10px"
              type="default"
              @click="reset"
            ></el-button>
            <div style="float: right">
              <el-tooltip content="添加" placement="top">
                <el-button
                  icon="plus"
                  style="width: 50px"
                  type="primary"
                  @click="add"
                ></el-button>
              </el-tooltip>
            </div>
          </div>
        </div>
        <!--    表格-->
        <el-table
          v-loading="loading"
          :data="tableData"
          border
          max-height="705"
          style="width: 100%"
        >
          <el-table-column label="#" type="index" />
          <el-table-column label="账号" prop="dormManager.username" sortable />
          <el-table-column label="姓名" prop="dormManager.name" />
          <el-table-column
            :filter-method="filterTag"
            :filters="[
              { text: '男', value: '男' },
              { text: '女', value: '女' },
            ]"
            filter-placement="bottom-end"
            label="性别"
            prop="dormManager.gender"
          />
          <el-table-column label="年龄" prop="dormManager.age" sortable />
          <el-table-column label="手机号" prop="dormManager.phoneNum" />
          <el-table-column label="邮箱" prop="dormManager.email" />
          <el-table-column
            label="任职宿舍楼"
            prop="dormManager.dormBuildId"
            sortable
          />
          <el-table-column label="角色" prop="roleName" />
          <!--      操作栏-->
          <el-table-column label="操作" width="130px">
            <template #default="scope">
              <el-button
                icon="Edit"
                type="primary"
                @click="handleEdit(scope.row)"
                >编辑</el-button
              >
              <el-popconfirm
                title="确认删除？"
                @confirm="handleDelete(scope.row.username)"
              >
                <template #reference>
                  <el-button icon="Delete" type="danger"></el-button>
                </template>
              </el-popconfirm>
            </template>
          </el-table-column>
        </el-table>
        <!--分页-->
        <div style="margin: 10px 0">
          <el-pagination
            v-model:currentPage="currentPage"
            :page-size="pageSize"
            :page-sizes="[10, 20]"
            :total="total"
            layout="total, sizes, prev, pager, next, jumper"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          >
          </el-pagination>
        </div>
        <div>
          <!--      弹窗-->
          <el-dialog
            v-model="dialogVisible"
            title="操作"
            width="30%"
            @close="cancel"
          >
            <el-form
              ref="form"
              :model="form"
              :rules="rules"
              label-width="120px"
            >
              <el-form-item label="账号" prop="username">
                <el-input
                  v-model="form.username"
                  :disabled="judgeAddOrEdit"
                  style="width: 80%"
                ></el-input>
              </el-form-item>
              <el-form-item label="密码" prop="password">
                <el-input
                  v-model="form.password"
                  :disabled="disabled"
                  :show-password="showpassword"
                  style="width: 80%"
                ></el-input>
                <el-tooltip content="修改密码" placement="right">
                  <el-icon
                    :style="editDisplay"
                    size="large"
                    style="margin-left: 5px; cursor: pointer"
                    @click="EditPass"
                  >
                    <edit />
                  </el-icon>
                </el-tooltip>
              </el-form-item>
              <el-form-item :style="display" label="确认密码" prop="checkPass">
                <el-input
                  v-model="form.checkPass"
                  :show-password="showpassword"
                  style="width: 80%"
                ></el-input>
              </el-form-item>
              <el-form-item label="姓名" prop="name">
                <el-input v-model="form.name" style="width: 80%"></el-input>
              </el-form-item>
              <el-form-item label="年龄" prop="age">
                <el-input
                  v-model.number="form.age"
                  style="width: 80%"
                ></el-input>
              </el-form-item>
              <el-form-item label="性别" prop="gender">
                <el-radio v-model="form.gender" label="男">男</el-radio>
                <el-radio v-model="form.gender" label="女">女</el-radio>
              </el-form-item>
              <el-form-item label="手机号" prop="phoneNum">
                <el-input
                  v-model.number="form.phoneNum"
                  style="width: 80%"
                ></el-input>
              </el-form-item>
              <el-form-item label="邮箱地址" prop="email">
                <el-input v-model="form.email" style="width: 80%"></el-input>
              </el-form-item>
              <el-form-item label="任职宿舍楼" prop="dormBuildId">
                <el-select
                  v-model="form.dormBuildId"
                  placeholder="请输入楼层"
                  style="width: 80%"
                >
                  <el-option label="一号楼" value="1" />
                  <el-option label="二号楼" value="2" />
                  <el-option label="三号楼" value="3" />
                  <el-option label="四号楼" value="4" />
                </el-select>
                <!-- <el-input
                  v-model="form.dormBuildId"
                  style="width: 80%"
                ></el-input> -->
              </el-form-item>
              <el-form-item label="角色" prop="roleId">
                <el-select
                  v-model="form.roleId"
                  placeholder="请选择角色"
                  style="width: 80%"
                >
                  <el-option
                    v-for="dorm in roleList"
                    :key="dorm.id"
                    :label="dorm.roleName"
                    :value="dorm.id"
                  />
                  <!-- <el-option label="一号楼" value="1" />
            <el-option label="二号楼" value="2" />
            <el-option label="三号楼" value="3" />
            <el-option label="四号楼" value="4" /> -->
                </el-select>
              </el-form-item>
            </el-form>
            <template #footer>
              <span class="dialog-footer">
                <el-button @click="cancel">取 消</el-button>
                <el-button type="primary" @click="save">确 定</el-button>
              </span>
            </template>
          </el-dialog>
        </div>
      </div>
    </el-card>
  </div>
</template>
<script src="@/assets/js/DormManagerInfo.js"></script>